<template>
  <el-card shadow="never" class="aui-card--fill">
    <h3 v-if="showNo" style="margin-top: 0">{{ $route.params.mtNo }}</h3>
    <div class="mod-wms__purchase-detail}">
      <wms-form v-model="dataForm" :formList="formList" :table-column="tableColumn" :advanced="advanced"
        @check-change="checkChange" @changeAdvance="changeAdvance" @getDataList="getDataList" @getReset="getReset">
        <el-form-item v-if="showNo">
          <el-button v-if="$hasPermission('wms:purchase-detail:save')" type="primary" @click="addOrUpdateHandle()">{{
            $t("add") }}</el-button>
        </el-form-item>
      </wms-form>
      <wms-table ref="wmsTable" v-model="dataForm" :page="page" :total="total" :limit="limit" :tableData="dataList"
        :table-column="column" :module-options="mixinViewModuleOptions" :dataListLoading="dataListLoading"
        :showSelection="true" @deleteHandle="deleteHandle" @addOrUpdateHandle="addOrUpdateHandle"
        @pageSizeChangeHandle="pageSizeChangeHandle" @pageCurrentChangeHandle="pageCurrentChangeHandle"
        @dataListSelectionChangeHandle="dataListSelectionChangeHandle" />
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './components/purchase-detail-add-or-update'
import { formList, tableColumn } from './config'
import wmsTable from '@/components/wms-table'
import wmsForm from '@/components/wms-form'
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        createdIsNeed: false,
        getDataListURL: '/wms/purchase-detail/pageCP',
        getDataListIsPage: true,
        exportURL: '/wms/purchase-detail/export',
        deleteURL: '/wms/purchase-detail',
        deleteIsBatch: true,
        deleteIsBatchKey: 'detailId'
      },
      showNo: false,
      formList,
      tableColumn,
      dataForm: {
        detailId: '',
        purchaseId: '',
        deliverNo: '',
        spuNo: ''
      }
    }
  },
  components: {
    AddOrUpdate,
    wmsTable,
    wmsForm
  },
  created() {
    if (this.$route.params.purchaseId) {
      this.showNo = true
      this.dataForm.purchaseId = this.$route.params.purchaseId
      this.dataForm.deliverNo = this.$route.params.deliverNo
    }
    this.query()
  },
  methods: {
    //0.重置搜索框
    getReset() {
      this.dataForm = this.$options.data().dataForm;
    }
  },
}
</script>